Skip to content

fix(studio): scrubbing across a cut shows the newest frame, not black - #8501

Merged
miguel-heygen merged 3 commits into
mainfrom
fix/studio-scrub-cut-cover
Nov 22, 2026
Merged

miguel-heygen merged 3 commits into
mainfrom
fix/studio-scrub-cut-cover

Conversation

@miguel-heygen

@miguel-heygen miguel-heygen commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

What

Scrubbing the preview across a cut shows the new clip's frame instead of a black one. The paused-frame host in Studio now decodes the newest frame it's asked for. Before, it refused that ask while an older, cancelled decode was still finishing.

Why

Since #8466, the preview frame asks Studio for each paused video frame over a port, and Studio's host runs one decode at a time. While you drag the playhead, the frame cancels the decode for the old position and immediately asks for the new one. The host kept the cancelled decode's slot until that decode finished, so it answered the new ask "Preview decoder busy", and nothing asked again. With no decoded frame for where the drag stopped, the preview fell back to the video element, which has no frame yet at the first moment of a new clip: black.

Refusing was the wrong answer for a scrub: the ask it dropped was always the newest one, the frame the drag stopped on. A continuous-sample drag across the cut, on the current main (6 runs each, unsealed and sealed), got "Preview decoder busy" twice in every run and showed black in 3 of 12 runs. With this change: no "busy", and black in 0 of 12.

The Studio timeline viewport gate catches this. Its drag into scene B sampled pure black (0,0,0) at the cut in the unsealed preview, in every failing run since #8466 and in none of the 87 passing runs before it.

How

  • pausedFrameHost is latest-wins. A new ask cancels any decode still running for an older one, and that older ask gets a failed reply ("Preview decode replaced"), so the frame never waits on it.
  • The new ask waits for the cancelled decode to finish, then decodes. The decoder still never runs two decodes at once.
  • An ask whose turn comes after it was itself cancelled decodes nothing.
  • This replaces the rule that a decode asked for while one runs is refused. The decode work stays bounded: one decode runs, only the newest ask waits to decode, and every older one is answered and skipped. The limits on sources per decode and on frame bytes are unchanged.

Before

The gate's drag into scene B on main: the clock reads B, the background is black.

Before: scene B mid-drag shows a black background

After

The same drag with this change: scene B mid-drag shows its blue background.

After: scene B mid-drag shows its blue background

Test plan

fails without the fix: "decodes the newest ask once an aborted decode settles, never two at once" in packages/studio/src/player/lib/pausedVideoProvider.test.ts

  • That row and the updated "replaces a decode a newer one overtakes" row fail on the current host. Removing the wait for the cancelled decode (two decodes at once) fails both. 12 of 12 in the file, 3 runs in a row.
  • A flood of 20 asks gets 19 "replaced" answers, exactly one decoder call runs at a time, and only the newest is decoded (fails on the current host and with the wait removed). A decoder that throws on one ask still lets the next one decode.
  • Continuous-sample drags across the cut in the browser, 6 runs per cell: black in 1 of 6 unsealed and 2 of 6 sealed runs on main, 0 of 6 in each with this change; "Preview decoder busy" 12 per cell on main, 0 with it.
  • packages/studio/src/player: 2680 tests in 219 files; core pausedFrames and pausedVideoFrames tests (19); Studio tsc clean.
  • The viewport gate passed in this PR's CI. It fails about 1 run in 6 without the fix, so the browser counts above are the proof, not this one run.

@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Edit accuracy: accurate 271 (base branch 271), smooth 63 of those

The gate passes.
Smoothness is reported in the artifact, not gated. A case fails only if it fails 2 of 3 runs.

Quarantined, measured but not gated (0)

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve at 216f8715.

Need ✅ (a scrub across a cut showed black; blocks v0.9.81) · Size ✅ (+86/−20, 2 files) · Reuse ✅ · Simpler ✅ · Structure ✅
Risk: low. The host still runs one decode at a time, and the limits on sources and frame bytes are unchanged. Only which ask wins changes: the newest now replaces the pending one, where before the newest was refused.

What I checked:

  • Fails without the fix: I put pausedVideoProvider.ts back to main. "decodes the newest ask once an aborted decode settles, never two at once" fails, and so do the updated "replaces a decode a newer one overtakes" row and the 20-ask flood row. At the head 12/12 pass, 3 runs in a row.
  • The wait is guarded by a test: with await previous dropped (two decodes at once), the same 3 rows fail, so the one-at-a-time rule is pinned.
  • The turn chain: asks A, B, C in a row: B aborts A and answers it "replaced", C does the same to B, and B skips its decode once A settles, so only C decodes. Each id gets exactly one reply: the replaced one's catch stays quiet because its signal is aborted, and send drops images for an aborted signal. A frame's own abort still cancels without a reply, as before. close aborts everything, and the waiting turns then skip.
  • Frame side: prepare (core pausedVideoFrames.ts) treats a failed reply like any decode error, the same path "busy" took before. Only which of two overlapping asks fails has changed.
  • Merge and types: merge-tree against current main is clean, and tsc --noEmit in studio is clean.

— Rames (hf-review)

@miguel-heygen
miguel-heygen added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit 0e6879b Nov 22, 2026
124 of 125 checks passed
@miguel-heygen
miguel-heygen deleted the fix/studio-scrub-cut-cover branch November 22, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants